home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / -seriously_amiga- / shareware / programming / e / easyplugins / source / iconbox.e < prev    next >
Text File  |  1997-12-06  |  4KB  |  203 lines

  1.  
  2. /*
  3.  
  4. */
  5.  
  6. OPT MODULE, OSVERSION=37
  7.  
  8. ->> iconbox_plugin: Modules
  9. MODULE 'tools/easygui', 'graphics/text',
  10.        'intuition/intuition', 'graphics/rastport'
  11.  
  12. MODULE 'utility', 'utility/tagitem'
  13.  
  14. MODULE 'workbench/workbench', 'workbench/startup', 'icon'
  15.  
  16. MODULE 'tools/ghost'
  17.  
  18. -><
  19.  
  20. /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  21.  
  22. ->> iconbox_plugin: Definitions
  23. EXPORT OBJECT iconbox_plugin OF plugin PRIVATE
  24.  
  25.     name
  26.     selected
  27.     disabled
  28.  
  29.     icon:PTR TO diskobject
  30.  
  31. ENDOBJECT
  32.  
  33. -> PROGRAMMER_ID | MODULE_ID
  34. ->      $01      |   $01
  35.  
  36. EXPORT ENUM PLA_IconBox_IconName=$81010001,
  37.             PLA_IconBox_ShowSelected,
  38.             PLA_IconBox_Disabled
  39.  
  40. -><
  41.  
  42. /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  43.  
  44. ->> iconbox_plugin: iconbox() & end()
  45.  
  46. PROC iconbox(tags:PTR TO tagitem) OF iconbox_plugin
  47.  
  48.     IF (utilitybase AND iconbase)
  49.  
  50.         self.name     := self.set(PLA_IconBox_IconName, GetTagData(PLA_IconBox_IconName, '', tags))
  51.         self.selected := GetTagData(PLA_IconBox_ShowSelected, FALSE, tags)
  52.         self.disabled := GetTagData(PLA_IconBox_Disabled, FALSE, tags)
  53.  
  54.     ELSE
  55.  
  56.         Raise("iblb")
  57.  
  58.     ENDIF
  59.  
  60. ENDPROC
  61.  
  62. PROC end() OF iconbox_plugin IS self.set(PLA_IconBox_IconName, NIL)
  63.  
  64. -><
  65.  
  66. ->> iconbox_plugin: set() & get()
  67.  
  68. PROC set(attr, value) OF iconbox_plugin
  69.  
  70.     SELECT attr
  71.  
  72.         CASE PLA_IconBox_IconName
  73.  
  74.             IF self.name<>value
  75.  
  76.                 IF self.icon
  77.  
  78.                     FreeDiskObject(self.icon)
  79.                     self.icon:=NIL
  80.  
  81.                 ENDIF
  82.  
  83.                 IF value
  84.  
  85.                     IF StrLen(value)>0
  86.  
  87.                         self.name:=value
  88.                         self.icon:=GetDiskObject(self.name)
  89.  
  90.                     ENDIF
  91.  
  92.                 ENDIF
  93.  
  94.                 IF (self.disabled=FALSE) THEN  self.draw(self.gh.wnd)
  95.  
  96.             ENDIF
  97.  
  98.         CASE PLA_IconBox_ShowSelected
  99.  
  100.             IF self.selected<>value
  101.  
  102.                 self.selected:=value
  103.  
  104.                 IF (self.disabled=FALSE) THEN self.draw(self.gh.wnd)
  105.  
  106.             ENDIF
  107.  
  108.         CASE PLA_IconBox_Disabled
  109.  
  110.             IF self.disabled<>value
  111.  
  112.                 self.disabled:=value
  113.  
  114.                 self.draw(self.gh.wnd)
  115.  
  116.             ENDIF
  117.  
  118.     ENDSELECT
  119.  
  120. ENDPROC
  121.  
  122. PROC get(attr) OF iconbox_plugin
  123.  
  124.     SELECT attr
  125.  
  126.         CASE PLA_IconBox_IconName;      RETURN self.name, TRUE
  127.         CASE PLA_IconBox_ShowSelected;  RETURN self.selected, TRUE
  128.         CASE PLA_IconBox_Disabled;      RETURN self.disabled, TRUE
  129.  
  130.     ENDSELECT
  131.  
  132. ENDPROC -1, FALSE
  133.  
  134. -><
  135.  
  136. ->> iconbox_plugin: draw()
  137. PROC draw(win:PTR TO window) OF iconbox_plugin
  138.  
  139.     IF win
  140.  
  141.         SetStdRast(win.rport)
  142.  
  143.         Box(self.x, self.y, (self.x+(self.xs-1)), (self.y+(self.ys-1)), 0)
  144.  
  145.         IF self.icon AND (self.disabled=FALSE)
  146.  
  147.             IF (self.icon.gadget.width < self.xs) AND (self.icon.gadget.height < self.ys)
  148.  
  149.                 DrawImage(win.rport,
  150.                           IF self.selected THEN self.icon.gadget.selectrender ELSE self.icon.gadget.gadgetrender,
  151.                           self.x+((self.xs-self.icon.gadget.width)/2), self.y+((self.ys-self.icon.gadget.height)/2))
  152.  
  153.             ENDIF
  154.  
  155.         ENDIF
  156.  
  157.         IF self.disabled THEN ghost(win, self.x, self.y, self.xs, self.ys)
  158.  
  159.     ENDIF
  160.  
  161. ENDPROC
  162. -><
  163.  
  164. ->> easygui standard procs
  165. PROC min_size(ta:PTR TO textattr, fh) OF iconbox_plugin
  166.  
  167.     DEF width, height
  168.  
  169.     IF self.icon
  170.  
  171.         width:=self.icon.gadget.width + 16
  172.         height:=self.icon.gadget.height + 12
  173.  
  174.     ELSE
  175.  
  176.         width:=48
  177.         height:=32
  178.  
  179.     ENDIF
  180.  
  181. ENDPROC width, height
  182.  
  183. PROC will_resize() OF iconbox_plugin IS (RESIZEX OR RESIZEY)
  184.  
  185. PROC render(ta:PTR TO textattr, x, y, xs, ys, win:PTR TO window) OF iconbox_plugin
  186.  
  187.    self.draw(win)
  188.  
  189. ENDPROC
  190.  
  191. PROC appmessage(amsg:PTR TO appmessage, win:PTR TO window) OF iconbox_plugin
  192.  
  193.     DEF xok=FALSE, yok=FALSE
  194.  
  195.     xok:=(amsg.mousex>=(self.x)) AND (amsg.mousex<=(self.x+self.xs-1))
  196.     yok:=(amsg.mousey>=(self.y)) AND (amsg.mousey<=(self.y+self.ys-1))
  197.  
  198. ENDPROC ((xok AND yok) AND self.disabled)
  199.  
  200. -><
  201.  
  202.  
  203.